//
//  MerchantsList.swift
//  feiyu444
//
//  Created by hanweiguang on 2018/10/10.
//  Copyright © 2018年 hanweiguang. All rights reserved.
//

import Foundation
import  UIKit



class MerchantsListController: BaseVC , UITableViewDataSource , UITableViewDelegate{
    
    
    
    var table:UITableView!
    let arry:[String] = ["test1", "test2", "test3", "test4"]
    
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return arry.count
        
    }
    
    let identify = "homeCellId"
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        //https://www.jianshu.com/p/5adc18761666
        // 使用自定义的cell   listItemCell
        //        let cell = (table.dequeueReusableCell(withIdentifier: "cellID", for: indexPath)) as UITableViewCell
        
        
        
        var cell:RescueItem! = tableView.dequeueReusableCell(withIdentifier: identify)as?RescueItem
        
        if cell == nil {
            
            cell = RescueItem(style: .default, reuseIdentifier: identify)
            
        }
        //去掉默认按下效果
        cell.selectionStyle=UITableViewCell.SelectionStyle.none
    
      
        return cell
        
        
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title="商户列表"
        self.createBtnBack();
        //设置UITableView的位置
        let rect = self.view.frame
        
        table = UITableView(frame: rect)
        
        //设置数据源
        self.table.dataSource = self
        //设置代理
        self.table.delegate = self
        self.view.addSubview(table)
 
        self.table.rowHeight = 150;
        
        //自适应布局的时候使用
        //        self.table.estimatedRowHeight = 150
        //        self.table.rowHeight = UITableView.automaticDimension;
        
        //去掉默认分割线
        self.table.separatorStyle = UITableViewCell.SeparatorStyle.none
        //注册UITableView，cellID为重复使用cell的Identifier
        self.table.register(UITableViewCell.classForCoder(), forCellReuseIdentifier:"cell")
        
        
    }
    
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.showNavivagor()
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let vc = MineViewController()
        self.navigationController?.pushViewController(vc, animated: true)
    }
    

    
    
    //跳转传值
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        
    }
    
    
}
